package com.okq.dao;

import com.okq.dao.base.Impl.BaseDao;
import com.okq.entity.JobProductHistory;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 描述 : 工单产品处理历史记录
 * 作者 : zdl
 * 日期 : 2017/6/29 11:09
 */
@Repository
public class JobProductHistoryDao extends BaseDao {

    public void saveJobProductHistory(JobProductHistory jobProductHistory) {
        super.save(jobProductHistory);
    }

    public void updateJobProductHistory(JobProductHistory jobProductHistory){
        super.update(jobProductHistory);
    }

    /**
     * 根据工单产品Id查询处理历史list
     *
     * @param jpId 工单产品Id
     * @return list
     */
    public List<JobProductHistory> listJobProductHistoryByJpId(String jpId) {
        if (StringUtils.isNotBlank(jpId)) {
            String hql = "FROM JobProductHistory WHERE isDelete = 0 AND jpId = '" + jpId + "' ORDER BY createTime DESC ";
            return super.find(hql);
        }
        return null;
    }
}
